@extends('adminHead')
@section('title','配置')
@section('rightContent')
    <link href="/admin/assets/plugins/bootstrap-tagsinput/dist/bootstrap-tagsinput.css" rel="stylesheet" />
    <link href="/admin/assets/plugins/switchery/dist/switchery.min.css" rel="stylesheet" />
    <link href="/admin/assets/plugins/multiselect/css/multi-select.css"  rel="stylesheet" type="text/css" />
    <link href="/admin/assets/plugins/select2/select2.css" rel="stylesheet" type="text/css" />
    <link href="/admin/assets/plugins/bootstrap-select/dist/css/bootstrap-select.min.css" rel="stylesheet" />
    <div class="content-page">
        <!-- Start content -->
        <div class="content">
            <div class="container">
    <div class="row">
        <div class="col-sm-12">
            <h4 class="page-title">配置</h4>
            <ol class="breadcrumb">
                <li>
                    <a href="/admin/companySettingsList">首页</a>
                </li>
                <li>
                    <a href="/admin/companySettingsAdd">保单信息导入</a>
                </li>
                <li class="active">
                    导入excel
                </li>
            </ol>
        </div>
    </div>
    <div class="row">
        <div class="col-sm-12">
            <div class="card-box">
                @if (count($errors) > 0)
                    <div class="alert alert-danger">
                        <ul>
                            @foreach ($errors->all() as $error)
                                <li>{{ $error }}</li>
                            @endforeach
                        </ul>
                    </div>
                @endif
                <form class="form-horizontal" id="forms">
                    <input type="hidden" name="_token" value="{{csrf_token()}}"/>
                    <div class="form-group">
                        <label class="col-md-2 control-label">选择公司*</label>
                        <div class="col-md-8">
                            <select class="form-control selectpicker"  data-style="btn-white" name="cid" id="">
                                @foreach($data['list'] as $item)
                                    <option value="{{$item['id']}}">{{$item['title']}}</option>
                                @endforeach
                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-md-2 control-label">配置手续费比例（小数）*</label>
                        {{--<div class="col-md-2">--}}
                            {{--<input type="text" name="insured" class="form-control" placeholder="车船税手续费比例" value="{{$data['model']['insured']}}" />--}}
                        {{--</div>--}}
                        <div class="col-md-2">
                            <input type="text" name="s_processing_fee_ratio" class="form-control" placeholder="商业险手续费比例" value="{{$data['model']['s_processing_fee_ratio']}}" />
                        </div>
                        <div class="col-md-2">
                            <input type="text" name="j_processing_fee_ratio" class="form-control" placeholder="交强险手续费比例" value="{{$data['model']['j_processing_fee_ratio']}}" />
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-md-2 control-label">选择文件（excel）*</label>
                        <div class="col-md-8">
                            <input type="file" id="excel" name="file" />
                        </div>
                    </div>
                    @if(count($data['model']) > 0)
                        <input type="hidden" name="id" value="{{$data['model']['id']}}" />
                        @endif
                    <div class="form-group">
                        <label class="col-md-2 control-label"></label>
                        <div class="col-md-8">
                            <button type="submit" class="btn btn-success" id="form">提交</button>
                        </div>
                    </div>
                </form>
            </div>
            <div class="card-box">
                <div class="content">
                    <div class="container">
                <div class="panel-body">
                <div class="">
                    <table id="table"
                           class="table-bordered">
                        <thead>
                        <tr>
                            <th data-field="id">ID</th>
                            <th data-field="number">保单号</th>
                            <th data-field="license_plate_number">车牌号</th>
                            <th data-field="policy_holder">投保人</th>
                            <th data-field="insured">被保人</th>
                            <th data-field="cname">公司名称</th>
                            <th data-field="compulsory_insurance">交强险保费</th>
                            <th data-field="j_processing_fee_ratio">交强手续费比例</th>
                            <th data-field="j_service_charge">交强手续费金额</th>
                            <th data-field="">商业险保费</th>
                            <th data-field="s_processing_fee_ratio">商业险手续费比例</th>
                            <th data-field="s_service_charge">商业险手续费金额</th>
                            <th data-field="vehicles_vessels">车船税</th>
                            <th data-field="j_application_fee">交强险申请费用</th>
                            <th data-field="c_application_fee">车船税申请费用</th>
                            <th data-field="s_application_fee">商业险申请费用</th>
                            <th data-field="total_cost">合计费用</th>
                        </tr>
                        </thead>
                        <tbody>

                        </tbody>
                    </table>
                </div>
                </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
            </div>
        </div>
    </div>
    <script>
      var resizefunc = [];
    </script>

    <!-- jQuery  -->
    <script src="/admin/assets/js/jquery.min.js"></script>
    <script src="/admin/assets/js/bootstrap.min.js"></script>
    <script src="/admin/assets/js/detect.js"></script>
    <script src="/admin/assets/js/fastclick.js"></script>
    <script src="/admin/assets/js/jquery.slimscroll.js"></script>
    <script src="/admin/assets/js/jquery.blockUI.js"></script>
    <script src="/admin/assets/js/waves.js"></script>
    <script src="/admin/assets/js/wow.min.js"></script>
    <script src="/admin/assets/js/jquery.nicescroll.js"></script>
    <script src="/admin/assets/js/jquery.scrollTo.min.js"></script>

    {{--<script src="/admin/assets/plugins/bootstrap-tagsinput/dist/bootstrap-tagsinput.min.js"></script>--}}
    {{--<script src="/admin/assets/plugins/switchery/dist/switchery.min.js"></script>--}}
    <script type="text/javascript" src="/admin/assets/plugins/multiselect/js/jquery.multi-select.js"></script>
    <script type="text/javascript" src="/admin/assets/plugins/jquery-quicksearch/jquery.quicksearch.js"></script>
    <script src="/admin/assets/plugins/select2/select2.min.js" type="text/javascript"></script>
    <script src="/admin/assets/plugins/bootstrap-select/dist/js/bootstrap-select.min.js" type="text/javascript"></script>
    <script src="/admin/assets/plugins/bootstrap-select/dist/js/i18n/defaults-zh_CN.js" type="text/javascript"></script>
    <script src="/admin/assets/plugins/bootstrap-filestyle/src/bootstrap-filestyle.min.js" type="text/javascript"></script>
    <script src="/admin/assets/plugins/bootstrap-touchspin/dist/jquery.bootstrap-touchspin.min.js" type="text/javascript"></script>
    <script src="/admin/assets/plugins/bootstrap-filestyle/src/bootstrap-filestyle.min.js" type="text/javascript"></script>
    <script src="/admin/assets/plugins/bootstrap-touchspin/dist/jquery.bootstrap-touchspin.min.js" type="text/javascript"></script>
    <script src="/admin/assets/plugins/bootstrap-maxlength/bootstrap-maxlength.min.js" type="text/javascript"></script>
    <script type="text/javascript" src="/admin/assets/plugins/parsleyjs/dist/parsley.min.js?p=8"></script>

    <script src="https://cdn.bootcss.com/bootstrap-table/1.13.1/bootstrap-table.min.js"></script>
    <script src="https://cdn.bootcss.com/bootstrap-table/1.13.1/extensions/export/bootstrap-table-export.min.js"></script>
    <script src="https://cdn.bootcss.com/xlsx/0.14.1/xlsx.core.min.js"></script>
    <script src="https://cdn.bootcss.com/FileSaver.js/2014-11-29/FileSaver.min.js"></script>
    <script src="/admin/assets/js/tableExport.min.js"></script>


    <script src="/admin/assets/js/jquery.core.js"></script>
    <script src="/admin/assets/js/jquery.app.js"></script>

    <script>
      var S = {
        bid:0
      }
      jQuery(document).ready(function() {
        // Select2

        $("#forms").on('submit',function (e) {
          e.preventDefault();
          var formData = new FormData($("#forms")[0]);
          $.ajax({
            url: "/admin/excelSave",
            data: formData,
            type: "POST",
            dataType: "json",
            contentType: false,//这里
            processData: false,//这两个一定设置为false
            success: function (res) {
              // console.log(res)
              S.bid = res.data[1].bid
              $('#table').bootstrapTable('destroy')
              bTable();
              // $("#table").bootstrapTable('refresh');
            },
            fail:function (res) {
                console.log(res)
            }
          });
          return false;
        })
          bTable();
        $(".select2").select2();
        $("input[name=type]").on('change',function () {
          let id = $(this).val()
            $(".type"+id).show().siblings().hide();
        })
        $(".select2-limiting").select2({
          maximumSelectionLength: 2
        });
        // $('form').parsley();
        $('.selectpicker').selectpicker();
        $(":file").filestyle({input: false});
        if($("#elm1").length > 0){
          tinymce.init({
            selector: "textarea#elm1",
            theme: "modern",
            height:300,
            style_formats: [
              {title: 'Bold text', inline: 'b'},
              {title: 'Red text', inline: 'span', styles: {color: '#ff0000'}},
              {title: 'Red header', block: 'h1', styles: {color: '#ff0000'}},
              {title: 'Example 1', inline: 'span', classes: 'example1'},
              {title: 'Example 2', inline: 'span', classes: 'example2'},
              {title: 'Table styles'},
              {title: 'Table row 1', selector: 'tr', classes: 'tablerow1'}
            ]
          });
        }
      });
      // function on_area() {
      //   var $area = $("#area");
      //   $("select[name=city]").next().find('li').on('click',function () {
      //     console.log('a')
      //     var text = trim($(this).find('.text').text());
      //     $.get('/admin/getCity',{text:text},function (res) {
      //       $area.html();
      //       var option = '';
      //       $.each(res,function (index,item) {
      //         option+='<option value="'+item.id+'">'+item.name+'</option>';
      //       });
      //       var str = "<select class='selectpicker bs-select-hidden' data-live-search='true' data-style='btn-white' name='area'>"+option+"</select>"
      //       $area.html(str);
      //       $area.find('select').selectpicker()
      //     })
      //   })
      // }
      function bTable() {
        console.log(S.bid)
        $("#table").bootstrapTable({
          url:'/admin/getList?bid='+S.bid,
          dataType:'json',
          method:'get',
          showExport: true,
          exportDataType: 'all',
          showColumns:true,
          pagination:true,
          sortName:'created_at',
          sortOrder:"desc",
          pageSize:"100",
          checkbox:true,
          pageList:"[100, 150, 200,All]",
          search:true,
          smartDisplay:true,
          exportTypes:['xlsx'],
          columns:[]
        });
      }
      function trim(param) {
        return param.replace(/(^\s*)|(\s*$)/g, "");
      }
    </script>

@endsection